var mo, ch; // 两个id
var ct = ci = cc = cr = false; //目标 导入 内容 小节

// 生成选项页面：输入id 、选择目标、导入、内容、小节
$("body").append(
	`<div class="sc" style="width: 50%;position: fixed;z-index: 9999;left: 0;right:0;top: 60%;background: pink;margin:0 auto;padding:15px">
				<span style="position: absolute;padding:10px; right: 0;top: 0;" id="sc_close">&times;</span>
				<div class="sc_group">
					<input type="text" placeholder="ModelId" id="sc_mo">
					<input type="text" placeholder="ChapterId" id="sc_ch">
				</div>
				<div class="sc_group">
					目标:<input type="checkbox" id="sc_target"> &emsp;&emsp;
					引入:<input type="checkbox" id="sc_import"> &emsp;&emsp;
					内容:<input type="checkbox" id="sc_content"> &emsp;&emsp;
					小节:<input type="checkbox" id="sc_review"> &emsp;&emsp;
				</div>
				<div class="sc_group">
					<button id="sc_btn">转移</button>
				</div>
			</div>`
)

// 转移：根据选择进行对应内容转移
$("#sc_btn").click(function() {
	mo = $("#sc_mo").val();
	ch = $("#sc_ch").val();
	if (mo == false || ch == false) {
		alert("缺少id，请重新运行")
		return;
	}

	console.log($("#sc_target").prop("checked"))
	console.log($("#sc_import").prop("checked"))
	console.log($("#sc_content").prop("checked"))
	console.log($("#sc_review").prop("checked"))

	if ($("#sc_target").prop("checked")) {
		// 课程目标
		$("#target").find("textarea").each(function() {
			console.log("目标：" + $(this).html())
			$.ajax({
				url: "/Admin/StandPlanChapter/AddSingleTarget",
				type: "post",
				dataType: "json",
				data: {
					ModelId: mo,
					ChapterId: ch,
					Content: $(this).html(),
					IsPoint: "false",
					IsDifficult: "false",
					Duration: "10",
					ContentType: 1
				},
				success: function(data) {
					console.log("目标成功")
				}
			})
		})
	}
	if ($("#sc_import").prop("checked")) {
		// 课前导入
		$("#import").find("textarea").each(function() {
			console.log("引入：" + $(this).html())
			$.ajax({
				url: "/Admin/StandPlanChapter/AddSingleTarget",
				type: "post",
				dataType: "json",
				data: {
					ModelId: mo,
					ChapterId: ch,
					Content: $(this).html(),
					IsPoint: "false",
					IsDifficult: "false",
					Duration: "10",
					ContentType: 2
				},
				success: function(data) {
					console.log("引入成功")
				}
			})
		})
	}
	if ($("#sc_content").prop("checked")) {
		// 教学内容
		$("#TeachContent").find("pre").each(function() {
			console.log("内容：" + $(this).text())
			$.ajax({
				url: "/Admin/StandPlanChapter/AddSingleTarget",
				type: "post",
				dataType: "json",
				data: {
					ModelId: mo,
					ChapterId: ch,
					Content: $(this).text(),
					IsPoint: "false",
					IsDifficult: "false",
					Duration: "10",
					ContentType: 3
				},
				success: function(data) {
					console.log("内容成功")
				}
			})
		})
	}
	if ($("#sc_review").prop("checked")) {
		// 课程总结
		$("#Review").find("textarea").each(function() {
			console.log("小节：" + $(this).html())
			$.ajax({
				url: "/Admin/StandPlanChapter/AddSingleTarget",
				type: "post",
				dataType: "json",
				data: {
					ModelId: mo,
					ChapterId: ch,
					Content: $(this).html(),
					IsPoint: "false",
					IsDifficult: "false",
					Duration: "10",
					ContentType: 4
				},
				success: function(data) {
					console.log("小节成功")
				}
			})
		})
	}

})
// 关闭选项页面
$("#sc_close").click(function(){
	console.log("删除")
	$(".sc").remove()
})
